<?php

class Zend_View_Helper_Admin
{
    protected static $stocks = array();

    /**
     * @return Zend_Navigation
     */
    protected function _initNavigation()
    {
        $config = array(
            Zend_Navigation_Page::factory(
                array(
                    'label' => 'Акции',
                    'uri'   => '/admin/stock/',
                    'route' => 'default'
                )
            ),
            Zend_Navigation_Page::factory(
                array(
                    'label' => 'Полезная информация',
                    'uri'   => '/admin/useful/',
                    'route' => 'default'
                )
            ),
            Zend_Navigation_Page::factory(
                array(
                    'label' => 'Галерея',
                    'uri'   => '/admin/gallery/',
                    'route' => 'default'
                )
            ),
            Zend_Navigation_Page::factory(
                array(
                    'label' => 'Аренда инструмента',
                    'uri'   => '/admin/rentcat/',
                    'route' => 'default'
                )
            ),
            Zend_Navigation_Page::factory(
                array(
                    'label' => 'Заявки на скидку в аренде',
                    'uri'   => '/admin/mail/',
                    'route' => 'mailrent'
                )
            ),
        );
        return new Zend_Navigation($config);
    }
    public function admin()
    {
        return $this;
    }

    public function navigation()
    {
        return $this->_initNavigation();
    }

    public function stocks()
    {
        if (self::$stocks) {
            return self::$stocks;
        }

        $mapper = new Application_Model_Mapper(new Application_Model_DbTable_Stock(), new Application_Model_Stock());
        self::$stocks = $mapper->getCollection(array(Application_Model_DbTable_Stock::FIELD_IS_ACTIVE => 1), 'stock_id DESC');
        return self::$stocks;
    }
}